import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ulearning_app/common/widgets/app_shadow.dart';
import 'package:ulearning_app/common/widgets/image_widgets.dart';
import 'package:ulearning_app/common/widgets/text_widgets.dart';

Widget appTextField({
  String text = '',
  String iconName = '',
  String hintText = '请输入',
  bool obscureText = false,
  void Function(String)? func,
}) {
  return Container(
    padding: EdgeInsets.only(left: 25.w, right: 25.w),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        text14Normal(text: text),
        SizedBox(height: 5.h),
        Container(
          width: 325.w,
          height: 50.h,
          decoration: appBoxDecorationTextField(),
          child: Row(
            children: [
              Container(
                margin: EdgeInsets.only(left: 17.w), //居中
                child: appImage(imagePath: iconName),
              ),
              SizedBox(
                width: 260.w,
                height: 50.h,
                child: TextField(
                  keyboardType: TextInputType.multiline, //多行输入框
                  decoration: InputDecoration(
                    hintText: hintText,
                    border: const OutlineInputBorder(
                      borderSide: BorderSide.none, //去掉边框
                    ),
                  ),
                  // onChanged: (value) => func!(value), //这种也行
                  onChanged: func, //监听输入
                  maxLines: 1, //设置此参数可以解决TextField只显示一行的问题
                  autocorrect: false, //关闭自动纠错功能
                  obscureText: obscureText, //密码不可见
                ),
              )
            ],
          ),
        )
      ],
    ),
  );
}
